import request from '@/utils/request'

//分类管理
const CAREGORY_URL = 'api/admin/category'

//新增分类
export const addCategory = (category)=>{
    return request.post(CAREGORY_URL,category)
}

//修改分类
export const updateCategory = (category)=>{
    return request.put(CAREGORY_URL,category)
}

//根据类型查询分类
export const list = (type)=>{
    return request.get(CAREGORY_URL+'/list',{
        params:{
            type:type
        }
    })
}

//分类分页查询
export const categoryPage = (name,page,pageSize,type)=>{
    return request.get(CAREGORY_URL+'/page',{
        params:{
            name:name,
            page:page,
            pageSize:pageSize,
            type:type
        }
    })
}

//启用禁用分类
export const status = (id,status)=>{
    // return request.post(CAREGORY_URL+'/status/'+status,{
    //     params:{
    //         id:id
    //     }
    // })

    return request.post(CAREGORY_URL+'/status/'+status+'?id='+id)
}

//根据id查找分类
export const queryCategoryById = (id)=>{
    console.log(typeof id)
    console.log(CAREGORY_URL+'/'+id)
    return request.get(CAREGORY_URL+'/'+id)
}